<template>
  <!-- 添加或修改盘点计划对话框 -->
  <el-dialog :title="title" v-if="open" v-model="open" width="600px" append-to-body>
    <div v-loading="loading">
      <el-form ref="form" :model="form" :rules="rules" label-width="130px" :inline="true">
        <el-form-item label="移交日期:" prop="handoverDate">
          <el-date-picker
            style="width: 100%"
            v-model="form.handoverDate"
            value-format="YYYY-MM-DD hh:mm:ss"
            type="date"
            placeholder="移交日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="跟单人:" prop="oldFollowUserId">
          <el-select :disabled="true" v-model="form.oldFollowUserId" clearable reserve-keyword placeholder="请选择跟单人">
            <el-option v-for="item in assistList" :key="item.userId" :label="item.realityName" :value="item.userId + ''" />
          </el-select>
        </el-form-item>
        <el-form-item label="跟单移交给:" prop="newFollowUserId">
          <el-select v-model="form.newFollowUserId" clearable reserve-keyword placeholder="请选择待跟单人">
            <el-option v-for="item in assistList" :key="item.userId" :label="item.realityName" :value="item.userId + ''" />
          </el-select>
        </el-form-item>

        <el-form-item label="移交原因:" prop="reasonForHandover">
          <el-input type="textarea" style="width: 1043px" :rows="4" v-model="form.reasonForHandover"></el-input>
        </el-form-item>
      </el-form>
    </div>

    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="submitForm" v-if="!isView">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script>
import modelMixin from '@/mixins/modelMixin';
import followTransfer from '@/api/goods/followTransfer';
import ImagePreview from '@/components/ImagePreview/index.vue';
import { getUserNotPermission } from '@/api/system/user';
import moment from 'moment';
export default {
  name: 'transer',
  components: {
    ImagePreview
  },
  mixins: [modelMixin],
  data() {
    return {
      title: '移交跟单',
      funcObj: followTransfer,
      form: {},
      open: false,
      rules: {
        handoverDate: [
          {
            required: true,
            message: '请选择移交日期',
            trigger: 'blur'
          }
        ],
        newFollowUserId: [
          {
            required: true,
            message: '请选待跟单人',
            trigger: 'blur'
          }
        ],
        reasonForHandover: [
          {
            required: true,
            message: '移交原因不能为空',
            trigger: 'blur'
          }
        ]
      }
    };
  },
  created() {
    this.getUserNotPermission();
  },
  methods: {
    edit(row) {
      this.open = true;
      (this.title = '移交跟单'),
        (this.form = { clueId: row.id, oldFollowUserId: row.followUserId + '', handoverDate: moment().format('YYYY-MM-DD hh:mm:ss') });
    },

    cancel() {
      this.open = false;
    },

    // 后台用户
    getUserNotPermission() {
      getUserNotPermission()
        .then((res) => {
          this.assistList = res;
        })
        .catch((err) => {
          console.log(err);
        });
    }
  }
};
</script>

<style lang="scss" scoped></style>